﻿using System;
using System.Data;
using System.Data.OracleClient;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/***************************************
 * Class Name:  DbConnection
 * Author:      Chen Xin
 * Version:     1.0
 * Date:        2006-10-26
 * Description: 建立数据库连接
 ***************************************/

/// <summary>
/// DbConnection 的摘要说明
/// </summary>
public class DbConnection
{
	public DbConnection()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    /// <summary>
    /// 获取 SqlServer 2005 数据库连接的一般方法
    /// </summary>
    /// <returns>返回数据库的一个 SqlConnection 连接</returns>
    public static SqlConnection GetConnection()
    {
        SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder();

        // 数据源类型
        connBuilder.DataSource = "HH-3SWEB";
        // 数据库名称
        connBuilder.InitialCatalog = "HongHe";
        connBuilder.UserID = "sss";
        connBuilder.Password = "sss";
        // 使用当前的 Windows 帐户进行身份验证
        // connBuilder.IntegratedSecurity = true;

        // 建立数据库连接
        SqlConnection conn = new SqlConnection(connBuilder.ConnectionString);

        // 返回一个 SqlConnection 连接
        return conn;
    }

    /// <summary>
    /// 获取 Oracle 9i 数据库连接的一般方法
    /// </summary>
    /// <returns>返回数据库的一个 SqlConnection 连接</returns>
    public static OracleConnection GetOracleConnection()
    {
        OracleConnectionStringBuilder oracleBuilder = new OracleConnectionStringBuilder();

        oracleBuilder.DataSource = "hhyc";
        oracleBuilder.UserID = "system";
        oracleBuilder.Password = "hhyc";

        OracleConnection conn = new OracleConnection(oracleBuilder.ConnectionString);
        return conn;
    }
}
